package com.lagou.springbootjpathymeleaf.example.service.impl;

import com.lagou.springbootjpathymeleaf.example.model.Article;
import com.lagou.springbootjpathymeleaf.example.repository.BlogSystemRepository;
import com.lagou.springbootjpathymeleaf.example.service.BlogSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class BlogSystemServiceImpl implements BlogSystemService {

    @Autowired
    private BlogSystemRepository blogSystemRepository;


    @Override
    public Page<Article> find(Integer page, Integer size) {
        Pageable pageable = new PageRequest(page, size, Sort.Direction.ASC, "id");
        return blogSystemRepository.findAll(pageable);
    }
}


